/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package reportcenter.auth.dominio;

import reportcenter.auth.dominio.Users;
import reportcenter.auth.dominio.*;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author renan
 */
@Entity
@Table(name = "AUTHORITIES")
@NamedQueries({@NamedQuery(name = "Authorities.findByIdAuth", query = "SELECT a FROM Authorities a WHERE a.idAuth = :idAuth"), @NamedQuery(name = "Authorities.findByAuthority", query = "SELECT a FROM Authorities a WHERE a.authority = :authority")})
public class Authorities implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID_AUTH", nullable = false)
    private Integer idAuth;
    @Column(name = "AUTHORITY", nullable = false)
    private String authority;
    @JoinColumn(name = "USERNAME", referencedColumnName = "USERNAME")
    @ManyToOne
    private Users username;

    public Authorities() {
    }

    public Authorities(Integer idAuth) {
        this.idAuth = idAuth;
    }

    public Authorities(Integer idAuth, String authority) {
        this.idAuth = idAuth;
        this.authority = authority;
    }

    public Integer getIdAuth() {
        return idAuth;
    }

    public void setIdAuth(Integer idAuth) {
        this.idAuth = idAuth;
    }

    public String getAuthority() {
        return authority;
    }

    public void setAuthority(String authority) {
        this.authority = authority;
    }

    public Users getUsername() {
        return username;
    }

    public void setUsername(Users username) {
        this.username = username;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idAuth != null ? idAuth.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Authorities)) {
            return false;
        }
        Authorities other = (Authorities) object;
        if ((this.idAuth == null && other.idAuth != null) || (this.idAuth != null && !this.idAuth.equals(other.idAuth))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "reportcenter.auth.dominio.Authorities[idAuth=" + idAuth + "]";
    }

}
